<template>
  <div class="app-container add">
    <el-form
      ref="ruleForm"
      :model="ruleForm"
      :rules="rules"
      label-width="100px"
      size="mimi"
    >
      <el-form-item label="仓库编号" prop="cpo">
        <el-input v-model="ruleForm.cpo" placeholder="仓库编号" />
      </el-form-item>
      <el-form-item label="仓库类型" prop="ctype">
        <el-select v-model="ruleForm.cname" placeholder="请选择活动区域">
          <el-option label="产品仓库" value="shanghai" />
          <el-option label="废品仓库" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="仓库名称" prop="cname">
        <el-input v-model="ruleForm.ctype" />
      </el-form-item>
      <el-form-item label="面积" prop="area">
        <el-input v-model="ruleForm.area" />
      </el-form-item>
      <el-form-item label="地址" prop="address" placeholder="请输入供应商编名称">
        <el-input v-model="ruleForm.address" />
      </el-form-item>
      <el-form-item label="联系人" prop="people">
        <el-input v-model="ruleForm.people" />
      </el-form-item>
      <el-form-item label="电话" prop="phone">
        <el-input v-model="ruleForm.phone" />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          @click="submitForm('ruleForm')"
        >提交
        </el-button>
        <el-button type="">
          <router-link to="/basicInfo/wareHouseManage">取消</router-link>
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'Edit',
  data() {
    return {
      ruleForm: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      rules: {
        ctype: [
          { required: true, message: '请输仓库类型', trigger: 'blur' }

        ],
        zuoyong: [
          { required: true, message: '请输仓库作用', trigger: 'blur' }

        ],
        area: [
          { required: true, message: '请输入仓库面积', trigger: 'change' }
        ],

        address: [
          { required: true, message: '请输入仓库地址', trigger: 'change' }
        ],
        people: [
          { required: true, message: '请填写联系人', trigger: 'change' }
        ],
        phone: [
          { required: true, message: '请填电话号', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    submitForm(formName) {
      alert('添加成功')
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }

  }

}
</script>

<style scoped lang="scss">
.add {
  width: 500px;
}
</style>
